/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-09-01
 * Time: 12:10
 */

//单例模式(饿汉模式)
class Singleton {
    private static Singleton instance = new Singleton();
    private Singleton () {}

    public static Singleton getInstance() {
        return instance;
    }
}
public class Demo1 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();

        //Singleton s3 = new Singleton();

        System.out.println(s1 == s2);
        //System.out.println(s1 == s3);

    }
}
